#region Usings
using System.Linq;
using System.Security.Principal;
using System.Web.Mvc;
using BK.Model;
using BK.Repositories.Abstract;
#endregion

namespace BK.Web.UI.Controllers
{
    public class BaseBkController : Controller
    {
        private User _user;

        #region Readonly & Static Fields
        private readonly IUsersRepository _usersRepository;
        #endregion

        #region C'tors
        public BaseBkController(IUsersRepository usersRepository)
        {
            _usersRepository = usersRepository;
        }
        #endregion

        #region Instance Properties
        protected User LoggedInUser
        {
            get
            {
                if (_user == null)
                {
                    _user = _usersRepository.GetByEmail(User.Identity.Name);
                }
                return _user;
            }
        }
        #endregion
    }
}